<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Vue Router Demo</title>
    <script src="../../../js/vue.js"></script>
    <script src="../../../js/vue-router.js"></script>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f4f4f9;
            margin: 0;
            padding: 0;
            color: #333;
        }
        #app {
            max-width: 800px;
            margin: 50px auto;
            padding: 20px;
            background: #fff;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            text-align: center;
        }
        h1 {
            font-size: 2.5em;
            color: #2c3e50;
            margin-bottom: 20px;
        }
        h2 {
            font-size: 1.8em;
            color: #34495e;
            margin-bottom: 15px;
        }
        p {
            font-size: 1.2em;
            margin-bottom: 20px;
        }
        input {
            margin: 10px 0;
            padding: 10px;
            font-size: 1em;
            width: 80%;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        button {
            padding: 10px 20px;
            font-size: 1em;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        button:hover {
            background-color: #2980b9;
        }
        a {
            text-decoration: none;
            color: #3498db;
            font-weight: bold;
            margin: 0 10px;
        }
        a:hover {
            text-decoration: underline;
        }
        .active {
            font-weight: bold;
            color: red;
        }
        .router-link-active {
            color: red;
        }
        .fade-enter-active, .fade-leave-active {
            transition: opacity 0.5s ease;
        }
        .fade-enter, .fade-leave-to {
            opacity: 0;
        }
    </style>
</head>
<body>
    <div id="app">
        <h1>{{ message }}</h1>
        <p>
            <router-link to="/login" active-class="active">登录</router-link>
            <router-link to="/register" active-class="active">注册</router-link>
        </p>
        <transition name="fade">
            <router-view></router-view>
        </transition>
    </div>
    
    <script>
        // 登录组件
        var Login = {
            template: `
                <div>
                    <h2>登录</h2>
                    <div>用户名：<input type="text" placeholder="请输入用户名"></div>
                    <div>密码：<input type="password" placeholder="请输入密码"></div>
                    <button>登录</button>
                </div>
            `
        };

        // 注册组件
        var Register = {
            template: `
                <div>
                    <h2>注册</h2>
                    <div>用户名：<input type="text" placeholder="请输入用户名"></div>
                    <div>密码：<input type="password" placeholder="请输入密码"></div>
                    <button>注册</button>
                </div>
            `
        };

        // 实例化路由
        var router = new VueRouter({
            routes: [
                {
                    path: '/',
                    redirect: '/login' // 默认重定向到登录页面
                },
                {
                    path: '/login',
                    component: Login
                },
                {
                    path: '/register',
                    component: Register
                }
            ]
        });

        // 实例化 Vue
        var vm = new Vue({
            el: '#app',
            router: router,
            data: {
                message: '教务系统后台期末分数管理系统'
            }
        });
    </script>
</body>
</html>